package com.unionpay.fsas;

import com.unionpay.fsas.sdk.SDKUtil;
import com.unionpay.fsas.sdk.gm.GmSDKUtil;
import java.io.UnsupportedEncodingException;
import java.util.Map;
import net.sf.json.JSON;
import net.sf.json.JSONObject;

/**
 * @author caoqc
 * @Description:
 * @date 2021/12/07 10:05:01
 */
public class Test2 {
    public static void main(String[] args) throws UnsupportedEncodingException {
        String stringData = "acqInsCode=49983080&encoding=UTF-8&respCode=11&respMsg=验证签名失败[11100042007]&signMethod=02&signPubKeyCert=-----BEGIN CERTIFICATE-----\n" +
                "MIIC0DCCAnSgAwIBAgIFEEBzAUEwDAYIKoEcz1UBg3UFADBcMQswCQYDVQQGEwJD\n" +
                "TjEwMC4GA1UECgwnQ2hpbmEgRmluYW5jaWFsIENlcnRpZmljYXRpb24gQXV0aG9y\n" +
                "aXR5MRswGQYDVQQDDBJDRkNBIFRFU1QgU00yIE9DQTEwHhcNMjAxMTAzMDk1NTU4\n" +
                "WhcNMjUxMTAzMDk1NTU4WjB1MQswCQYDVQQGEwJDTjEQMA4GA1UECgwHT0NBMVNN\n" +
                "MjENMAsGA1UECwwEdGVzdDEZMBcGA1UECwwQT3JnYW5pemF0aW9uYWwtMjEqMCgG\n" +
                "A1UEAwwhMDUxQGNoaW5hdW5pb25wYXlAWjkwNTI5MDAwMDAwOEAyMFkwEwYHKoZI\n" +
                "zj0CAQYIKoEcz1UBgi0DQgAEkw27RvY8mAx6h7vnSW/+X3b++a1E6LzQTPWMOiKP\n" +
                "AfZTqJMKeRnQNEKt+N7EA98YHVheOCT9TlZ3fkgtNZcH86OCAQYwggECMB8GA1Ud\n" +
                "IwQYMBaAFGv+GNqPQjqmuG2zLoiDOjSiwTDhMAwGA1UdEwEB/wQCMAAwSAYDVR0g\n" +
                "BEEwPzA9BghggRyG7yoBATAxMC8GCCsGAQUFBwIBFiNodHRwOi8vd3d3LmNmY2Eu\n" +
                "Y29tLmNuL3VzL3VzLTE0Lmh0bTA5BgNVHR8EMjAwMC6gLKAqhihodHRwOi8vdWNy\n" +
                "bC5jZmNhLmNvbS5jbi9TTTIvY3JsMTM3MzYuY3JsMA4GA1UdDwEB/wQEAwIGwDAd\n" +
                "BgNVHQ4EFgQUn9wz++O90r2Bc7qlzqeIhIVivD4wHQYDVR0lBBYwFAYIKwYBBQUH\n" +
                "AwIGCCsGAQUFBwMEMAwGCCqBHM9VAYN1BQADSAAwRQIgNXTJts3vqvCbbhUKwnkI\n" +
                "rv+HeDeyTwU4JJpBTWCR6TACIQCtQShpYt9jgxw6VSHpKEXnnWH9u4vYhXDoH42w\n" +
                "WVaX6A==\n" +
                "-----END CERTIFICATE-----&signature=xbzX7K4TaPVi6kbR3xrHRv4s7AdK6+gFrrk4moviJGl4WqChK/RLRTd0xU4s12w7N0XbCtklj/HFupxpAbo/hA==&txnDate=20211207&txnNo=20211207103456498&txnType=01&version=1.0.0";

        stringData = stringData.replace("\n", "");
        stringData = stringData.replace("\r", "");

        System.out.println("待验签排序串：[" + stringData + "]");

        Map map =  SDKUtil.convertResultStringToMap(stringData);

        GmSDKUtil.verifySm2N(map, null,"UTF-8",null);

    }


}
